import http from "@/api/config/http";
import { ENUM_DATA_SCOPE } from "@/enum/system.enum";
import { IQuery, ITableResponse } from "@/interface/IAxios";
import { IStore } from "./types";

// 查询门店列表
export function listStore(query: IQuery): Promise<ITableResponse<IStore>> {
  console.log();
  query.scope = ENUM_DATA_SCOPE.THIS_AND_ALL_SUB;
  return http.request({
    url: "/store/store/list",
    method: "get",
    params: {
      ...query
    }
  });
}
// 删除门店
export function delStore(id: Array<string>) {
  return http.request({
    url: `/store/store/${id}`,
    method: "delete"
  });
}
// 查询门店
export function editStore(id: string) {
  return http.request({
    url: `/store/store/${id}`,
    method: "get"
  });
}

// 新增门店
export function addStore(data: IStore) {
  return http.request({
    url: "/store/store",
    method: "post",
    data
  });
}
// 修改门店
export function updateStore(data: IStore) {
  return http.request({
    url: "/store/store",
    method: "put",
    data
  });
}

// 修改附加信息
export function updateDetails(data: any) {
  return http.request({
    url: "/store/store/details",
    method: "post",
    data
  });
}

export function getDetails() {
  return http.request({
    url: "/store/store/details",
    method: "get"
  });
}
export function fetchStoreOptions() {
  return http.request({
    url: "store/store/options",
    method: "get"
  });
}

interface StoreResource {
  imageUrl: string;
  videoUrl: string;
}
export function storeResource(data: StoreResource) {
  return http.request({
    url: "store/store/resource",
    method: "post",
    data
  });
}
